﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using VanTaiProperty;
namespace VanTaiData
{
    public class TMCabin_Controller : clsConnect
    {
        private clsConnect cls = new clsConnect();
        #region[Get-Data]
        public DataTable BindCabin()
        {
            return cls.BindGridData("sp_TMCabin_Search");
        }
        public DataTable BindCabinDetail(int id)
        {
            return cls.LayDuLieuParameter("sp_TMCabin_Detail_Edit", "@Cabin_Id", id);
        }
        public DataTable BindCabinCarNo(int id)
        {
            return cls.LayDuLieuParameter("sp_TMCabin_CarNo", "@Vehicle_ID", id);
        }
        #endregion

        #region[Insert-Update-Delete-Delete]
        public bool InsertCabin(TMCabin_Property data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Cabin_Alias", data.Cabin_Alias);
            cls.AddParameter("@Cabin_Name", data.Cabin_Name);
            cls.AddParameter("@Vehicle_ID", data.Vehicle_ID);
            cls.AddParameter("@Cabin_Length", data.Cabin_Length);
            cls.AddParameter("@Cabin_Width", data.Cabin_Width);
            cls.AddParameter("@Cabin_Height", data.Cabin_Height);
            cls.AddParameter("@Cabin_Total", data.Cabin_Total);
            cls.ExecuteNonQuery("sp_TMCabin_Insert");
            return true;
        }
        public bool UpdateCabin(TMCabin_Property data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Cabin_Id", data.Cabin_Id);
            cls.AddParameter("@Cabin_Alias", data.Cabin_Alias);
            cls.AddParameter("@Cabin_Name", data.Cabin_Name);
            cls.AddParameter("@Vehicle_ID", data.Vehicle_ID);
            cls.AddParameter("@Cabin_Length", data.Cabin_Length);
            cls.AddParameter("@Cabin_Width", data.Cabin_Width);
            cls.AddParameter("@Cabin_Height", data.Cabin_Height);
            cls.AddParameter("@Cabin_Total", data.Cabin_Total);
            cls.ExecuteNonQuery("sp_TMCabin_Update");
            return true;
        }
        public bool DeleteCabin(int id)
        {
            cls.Delete("sp_TMCabin_Delete", "@Cabin_Id", id);
            return true;
        }
        #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMCabin_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}
